package toledo.post;

import java.io.IOException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.appengine.api.datastore.Entity;
import com.google.gdata.data.acl.AclRole;
import com.google.gdata.data.acl.AclScope;

import toledo.rest.Course;
import toledo.util.DocumentList;

public class AddEmailServlet extends HttpServlet
{
	private static final long serialVersionUID=1L;
	
	public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException
	{
		Entity course = Course.getCourse(req.getParameter(Course.COURSE_ID));
		DocumentList dl;
		try
		{
			dl = DocumentList.getService();
			dl.addAclRole(AclRole.READER,new AclScope(AclScope.Type.USER,req.getParameter("email")),course.getProperty(Course.DOCS_RES_ID).toString());
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
	 }
}